#ifndef CSTATELOGIN_H_INCLUDED
#define CSTATELOGIN_H_INCLUDED


#include "CState.h"

class CStateLogin : public CState
{
public:
    CStateLogin(CGameManager * mgr);
    virtual ~CStateLogin();

    void init();
    void close();
    void run();
    void enable();
    void disable();

    //! Event Receiving Methods
    void OnServerPacketReceived(Packet *packet);

    void OnClientPacketReceived(Packet *packet);

    //! Called when a GUI button
    bool OnButtonClick(s32 id);

    //! Called when other GUI events happens
    virtual bool OnGUIEvent(const SEvent& event);


  protected:
  private:
    //! Called when login button is pressed
    void login();

    //! Called when login is sucess
    void loginSucess(BitStream *bs);

    void requestCreateAccount();

    void ackCreateAccount(BitStream *bs);

    void showLoginPanel();

    void showCreateAccountWindow();


    IGUIEditBox *txtUsername;
    IGUIEditBox *txtPassword;

    IGUIWindow *caWindow;
    IGUIEditBox *txtCaUsername;
    IGUIEditBox *txtCaPassword1;
    IGUIEditBox *txtCaPassword2;

    IGUIEditBox *txtCaName;
    IGUIComboBox *comOverlordType;


    enum GUI_ID
    {
      BTN_LOGIN,
      BTN_POPSTATE,
      BTN_CREATE_ACCOUNT,
      BTN_CA_OK,
      BTN_CA_CANCEL,

      TXT_PASSWORD,

      MSG_DISCONNECT,
    };
};

#endif // CSTATELOGIN_H_INCLUDED
